/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Timeline.Core.Level;

import Timeline.Core.GameMain;
import Timeline.Core.GamePanel.GamePanel;
import Timeline.Imagem.Imagem;
import java.awt.Image;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 *
 * @author Lennon
 */
public class Event {
    private ArrayList<String[]> eventStart = null;
    private int indexStart = 0;
    private ArrayList<String[]> eventEnd = null;
    private int indexEnd = 0;
    
    public void addEvent(String key, String value, boolean start) {
        String[] array = {key, value};
        if (start){
            eventStart.add(array);
        }else{
            eventEnd.add(array);
        }
    }
    
    public void clearList(){
        eventStart.clear();
        eventEnd.clear();
        
        indexEnd = 0;
        indexStart = 0;
    }
    
    public boolean executeNext(boolean start){
        EnumEvento key;
        String value;
        if(start){
            if(indexStart != eventStart.size()){
                key = EnumEvento.valueOf(eventStart.get(indexStart)[0]);
                value = eventStart.get(indexStart)[1];
                indexStart++;
            }else{
                return false;
            }
        }else{
            if(indexEnd != eventEnd.size()){
                key = EnumEvento.valueOf(eventEnd.get(indexEnd)[0]);
                value = eventEnd.get(indexEnd)[1];                
                indexEnd++;
            }else{
                return false;
            }
        }
        
        switch(key){
            case background:
                changeBackground(value);
                break;
            case sound:
                changeSound(value);
                break;
        }
        return true;
    }

    private void changeBackground(String value) {
        GameMain.getInstance().changeBackground(value);
    }

    private void changeSound(String value) {
       // GameMain.getInstance().changeSound(value);
    }
}
